<%@ page contentType="text/html;charset=utf-8"%>
<html lang="zh">
<head>
<title>聊天----客服</title>
<script src="js/jquery-3.1.0.min.js"></script>
<script>
	$(document).ready(function() {
		//发送消息
		$("#talk").click(function(){
			var content=$("#lang").val();
			$.ajax({
				type:"post",
				url:"addChat2.action",
				data:{content:content},
				success:function(msg){
				}
			});
				$("#info").append("我:"+content+"\r");
				$("#lang").val("");
		});
		var id=-1;
		setInterval(function(){
			$.ajax({
				type:"post",
				url:"getChat2.action",
				data:{userFrom:"s10001"},
				success:function(msg){
					if(msg!="fail"){
						var newId=msg.split("_")[0];
						if(id!=newId){
							$("#info").append("用户:"+msg.split("_")[4]+"           "+msg.split("_")[3]+"\r");
							id=newId;
						}
						
					}
				}
			});
		},3000);
	});

	
	
	
</script>
<style type="text/css">
</style>
</head>
<body>
<div>
  
  
<div align="center">  
  <p>  
    <textarea rows="20" cols="50" id="info" readonly="readonly"></textarea>  
  </p>  
  <p>
    输入内容：  
      <input type="text"id="lang"value="" size="33"/>  
    <input type="button" value="发言"id="talk"style="font-family: 宋体; font-size: 9pt; color: #ffffff; background-color: #999900; border-width: 1pt; border-color: black; border-style: solid; CURSOR: hand">  
  </p>  
</div>  
  
</div>  
</body>